package com.sskj.aikeeper.presenter;


import android.util.Log;

import com.lzy.okgo.model.Response;
import com.sskj.aikeeper.bean.SignStatusBean;
import com.sskj.aikeeper.hangqing.activity.SignInActivity;
import com.sskj.common.base.HttpData;
import com.sskj.lib.BaseHttpConfig;
import com.sskj.lib.bean.CurrentTreasureBean;
import com.sskj.lib.bean.SignInBean;
import com.sskj.lib.bean.SignInListBean;
import com.sskj.lib.http.JsonCallBack;

import java.util.logging.Logger;

/**
 * @author Hey
 * Create at  2019/06/25
 */
public class SignInPresenter extends BasePresenter<SignInActivity> {
    public void getSignInState() {
        httpService.getSignInState()
                .tag(this)
                .execute(new JsonCallBack<HttpData<SignStatusBean>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<SignStatusBean>> response) {
                        if (response.body().status == BaseHttpConfig.OK) {
                            mView.getSignInState(response.body().getData());
                        }
                    }
                });
    }

    public void clickSignIn() {
        httpService.clickSignIn()
                .tag(this)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        mView.clickSignIn(response.body().status);
                    }
                });
    }

    public void getSignInList(boolean flag, int p, int size) {
        httpService.getSignInList(p, size)
                .tag(this)
                .execute(new JsonCallBack<HttpData<SignInListBean>>(flag ? this : null) {
                    @Override
                    public void onSuccess(Response<HttpData<SignInListBean>> response) {
                        mView.getSignInList(response.body().getData());
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();
                        mView.stopRefresh();
                    }
                });

    }
}
